<?php
header("Pragma: public");
header("Expires: 0");
header("Accept-Ranges: bytes");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename=abiturients.csv');
header("Content-Transfer-Encoding: binary");
$globalnumber = 0;
/* debug ($abiturientslist);
die(); */
foreach ($educationlevels as $eduid => $eduname):
	foreach ($professions as $profid => $profname):
		foreach ($learningforms as $lfid => $lfname):
			foreach ($learningtypes as $ltid => $ltname):
				if (!empty($abiturientslist[$eduid][$profid][$lfid][$ltid])) {
					$fios = $abiturientslist[$eduid][$profid][$lfid][$ltid];
					 sort($fios);
					$tmpnumber = 0;
					foreach ($fios as $fio):
					$tmpnumber++;
					$globalnumber++;
					$line = $globalnumber.';';
					if ($eduid == 1) {
						$line .= 'ВЫС';
					} else {
						$line .= 'СРЕДН';
					}
					$line .= ' '.$profname.';';
					$line .=$lfname.';'.$ltname.';'.$tmpnumber.';'.$fio.";0\n";
							echo $line;				
					endforeach;
				} else {
					continue;
				}
			endforeach;
		endforeach;
	endforeach;
endforeach;